#ifndef BACK_CHAINING_INFERENCE_HPP_GUARD
#define BACK_CHAINING_INFERENCE_HPP_GUARD

#include "strategy.hpp"
#include "../kb/kbase.hpp"

#include "../kb/search/facts_searcher.hpp"
#include "../kb/search/rules_searcher.hpp"
#include "../kb/search/analogy_facts_searcher.hpp"
#include "../kb/search/analogy_rules_searcher.hpp"

namespace mashine { namespace inference {
/**
 * this class provide backward chaining strategy logic inference
 */
class BackwardChainingStrategy : public InferenceStrategy
{
public:
	/**
	 * param kBase - pointer to knowlege base
	 */
	BackwardChainingStrategy(mashine::kb::KnowledgeBase * kBase);
	
	/**
	 * 
	 */
	~BackwardChainingStrategy();
	
	/**
	 * backward chaining algorithm
	 *
	 * param goal - list of goals to inference
	 */
	virtual std::vector<kb::Literal *> inference(std::vector<kb::Literal *> const & goal);
	
protected:
	mashine::kb::KnowledgeBase * kBase;
	
	mashine::kb::Literal * root;
	
	mashine::kb::search::FactsSearchVisitor * factSearcher;
	mashine::kb::search::AnalogyFactsSearchVisitor * aFactSearcher;
	mashine::kb::search::RulesSearchVisitor * ruleSearcher;
	mashine::kb::search::AnalogyRulesSearchVisitor * aRuleSearcher;
	
	void unification(mashine::kb::Literal * const & root);
	void production(mashine::kb::Literal * const & root);
};

}}

#endif